﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Media;
using System.Xml.Serialization;

namespace SharedUtils
{
    public class SoundEntity : Entity
    {
        public SoundEntityState state { get; set; }

        // Textures for Play, Pause, Stop buttons
        [XmlIgnore]
        public Texture2D play { get; set; }
        [XmlIgnore]
        public Texture2D pause { get; set; }
        [XmlIgnore]
        public Texture2D stop { get; set; }

        // Vector2 that scales Texture2D to proper size
        public Vector2 size { get; set; }

        // File locations for Textures
        public String playPath { get; set; }
        public String pausePath { get; set; }
        public String stopPath { get; set; }

        // Sound File for SoundEntity
        [XmlIgnore]
        public Song sound { get; set; }

        // File location for Sound
        public String soundPath { get; set; }

        public enum SoundEntityState
        {
            NONE,
            STOPPED,
            PLAYING,
            PAUSED
        }

        public SoundEntity()
            : base()
        {
            state = SoundEntityState.STOPPED;

            this.playPath = string.Empty;
            this.pausePath = string.Empty;
            this.stopPath = string.Empty;

            this.size = Vector2.Zero;

            this.soundPath = string.Empty;
        }

        public SoundEntity(String name, Vector2 position, String playPath, String pausePath, String stopPath, Vector2 size, String soundPath)
            : base(name, position)
        {
            state = SoundEntityState.STOPPED;

            this.playPath = playPath;
            this.pausePath = pausePath;
            this.stopPath = stopPath;

            this.size = size;

            this.soundPath = soundPath;
        }

        public SoundEntity(String name)
            : base(name)
        {
            state = SoundEntityState.STOPPED;
        }

        public SoundEntity(SoundEntity toCopy)
            : base(toCopy.name, toCopy.position)
        {
            this.state = toCopy.state;

            this.playPath = toCopy.playPath;
            this.pausePath = toCopy.pausePath;
            this.stopPath = toCopy.stopPath;

            this.size = toCopy.size;

            this.soundPath = toCopy.soundPath;
        }

        public override string ToString()
        {
            return base.ToString() + " - " + state;
        }
    }
}
